# Configuration

## Prepping

### Config

You can base your configuration on a sample file. To do that just copy `config.sample.sh` to `config.sh`. e.g.

```sh
cp -i config.sample.sh config.sh
```

`config.sh` is in `.gitignore` in this repository, so it will not be included in your commits.

### OAuth2 Setup

You would need to have an OAuth2 Application setup in your account. If you don't have one created already, when logged in, go to (Avatar) - Settings - Applications - Manage OAuth2 Applications. Enter Application Name as something like `Drone` and Redirect URL which is shown after you run `start.sh`, something like `https://(hostname)drone.ejemplo.me/login`. Click Create Application. It will give you a Client ID and a Secret. Take a note of both.

These will need to be entered in `DRONE_GITEA_CLIENT_ID` and `DRONE_GITEA_CLIENT_SECRET` in config.sh.

Once the application is created, the URL can be edited (in case it changes, e.g. if you use `localtunnel` for local tunneling it changes everytime you run start.sh).

## Explanation

For explanation you can consult the comments in the config.sh.

- `REPO_PROVIDER`: The software that is used to provide the repo service. Accepted values are:
  - `gitea` (enter this if you use codeberg.org)
  - `gogs` (enter this if you use notabug.org)
- `REPO_SERVER`: The homepage that you use to access your Gitea instance. If you use codeberg.org, enter `https://codeberg.org`
- `REPO_CLIENT_ID`: Client ID from OAuth2 application. Put the secret in `REPO_CLIENT_SECRET` (see below).
- `REPO_CLIENT_SECRET`: Put the client secret from your OAuth2 application. If you did the above, enter the secret as the value.
- `REPO_USERNAME`: Your Gitea/Codeberg.org username.
- `DRONE_RPC_SECRET`: This is just a random string that is shared between the main image and the runner. Run `openssl rand -hex 16` to get a random string and put it here.
- `DRONE_SERVER_HOST`: The host where you access Drone UI. Set this to the host if you have Drone running on a domain. Set this to 'AUTO' if you want a local tunneling service to give you an url to access it.
- `DRONE_SERVER_PROTO`: The protocol that you use to access `DRONE_SERVER_HOST`. e.g. `'https'`, `'http'`
- `TUNNELING_SERVICE`: Tunneling service which should be used if you have `'AUTO'` set as `DRONE_SERVER_HOST`.
- `TUNNELING_SERVICE_SUBDOMAIN`: Subdomain to be used with tunneling service (if supported). Some services, such as, `localtunnel` does not support this. Default: `"`uname -n`drone"`
- `TUNNELTO_API_KEY`: API Key for TunnelTo service. If you use this service get one and put it here. Otherwise ignore safely.
- `DRONE_RPC_PROTO`: Protocol of the URL which you access your runner. If you don't have runner running on a separate domain, ignore it. 
- `DRONE_RPC_HOST`: Host of the URL which you access your runner. If you don't have runner running on a separate domain, ignore it.
- `DOCKER_MAIN_NAME`: Name of the main image.
- `DOCKER_RUNNER_NAME`: Name of the runner image.

## Troubleshooting

If you have any problems not listed here, feel free to [post an issue](https://notabug.org/adnan360/droney/issues).

### My config is out of date

In future if the config structure is updated, your old config.sh may become out of date. Just keep a backup of your old config as something like `config.sh.bak`, copy the `config.sample.sh` to `config.sh` and put all the values from your backup to the new file.

You can also use a diff program, such as [meld](https://meldmerge.org/). Open both `config.sample.sh` and `config.sh` to see what has changed and make changes to config.sh as necessary.
